import { getComment, getCommentList, addComment, updateComment } from 'api/comment'

const comment = {
  state: {
  },
  mutations: {
  },
  actions: {
    // 获取评论列表
    GetCommentList({ commit }) {
      return new Promise((resolve, reject) => {
        getCommentList().then(response => {
          resolve(response.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    // 获取评论
    GetComment({ commit }, articleid) {
      return new Promise((resolve, reject) => {
        getComment(articleid).then(response => {
          resolve(response.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    // 评论
    AddComment({ commit }, info) {
      return new Promise((resolve, reject) => {
        addComment(info).then(response => {
          resolve(response.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    UpdateComment({ commit }, info) {
      return new Promise((resolve, reject) => {
        updateComment(info).then(response => {
          resolve(response.data)
        }).catch(err => {
          reject(err)
        })
      })
    }
  }
}
export default comment
